/**
 * @author:cloud.lg
 * @date:2021.7.26
 * @description: vuex模块 errorlog 错误日志模块 后续模块一律使用此规范
 */
 import Element from 'element-ui'

const state = {
  logs: []
}

const mutations = {
  ADD_ERROR_LOG: (state, log) => {
    state.logs.push(log)
    Element.Message({
        message: log,
        type: 'error'
    })
  },
  CLEAR_ERROR_LOG: (state) => {
    state.logs.splice(0)
  }
}

const actions = {
  addErrorLog({ commit }, log) {
    commit('ADD_ERROR_LOG', log)
  },
  clearErrorLog({ commit }) {
    commit('CLEAR_ERROR_LOG')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
